﻿<%@ Page Language="C#" Theme="Samples" AutoEventWireup="true" CodeFile="WebForm6.aspx.cs" Inherits="Samples_Prompt_WebForm6" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    
    
<script type="text/javascript">
    function prompt1_ButtonSelect(sender, args)
    {
        var prompt = $find('prompt1');
        var target = args.get_button().get_commandArgument() == 'prompt' 
            ? AfterEdge.Web.UI.PostBackTarget.Prompt 
            : AfterEdge.Web.UI.PostBackTarget.Trigger;
        
        prompt.set_postBackTarget(target);
    }
</script>
    
    
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="sm1" runat="server" />
    <div>
        <h2>Prompt Postback Targets</h2>
        <p>
            This sample demonstrates the PostBack target option of the prompt control.  
            The prompt may be neccesary to be to be injected in the middle of a workflow.  After the prompt is raised from a trigger, the control can be sent back to the trigger control.
            The prompt defaults to PostBackTarget.Prompt, but can be set to PostBackTarget.Trigger on both the client and the server.
        </p>
        <div>
            <div><asp:Label ID="message" ForeColor="Red" runat="server" /></div>
            <div></div><asp:Button ID="button1" Text="Show Prompt" OnClick="button1_Click" runat="server" /></div>
            <div><asp:Checkbox ID="checkbox1" Text="Show Prompt" AutoPostBack="true" OnCheckedChanged="checkbox1_CheckedChanged" runat="server" /></div>
            <div>
                <asp:DropDownList ID="ddl1" AutoPostBack="true" OnSelectedIndexChanged="ddl1_SelectedIndexChanged" runat="server">
                    <asp:ListItem Text="--Select--" />
                    <asp:ListItem Text="Item 1" />
                    <asp:ListItem Text="Item 2" />
                    <asp:ListItem Text="Item 3" />
                </asp:DropDownList>
            </div>
            
            <ae:Prompt ID="prompt1" Title="Sample 6" ButtonOptions="Custom" Message="What control should be the target of the postback?" OnCommand="prompt1_Command" runat="server">
                <ClientEvents>
                    <ButtonSelect EventHandler="prompt1_ButtonSelect" />
                </ClientEvents>
                <Buttons>
                    <ae:PromptButton ID="promptButton" Text="Prompt" CommandArgument="prompt" AutoPostBack="true" runat="server" />
                    <ae:PromptButton ID="triggerButton" Text="Trigger" CommandArgument="trigger" AutoPostBack="true" runat="server" />
                </Buttons>
                <Triggers>
                    <ae:ControlPromptTrigger ControlID="button1" EventName="click" PreventDefault="true" />
                    <ae:ControlPromptTrigger ControlID="checkbox1" EventName="click" PreventDefault="true" />
                    <ae:ControlPromptTrigger ControlID="ddl1" EventName="change" PreventDefault="true" />
                </Triggers>
            </ae:Prompt>
        </div>
    </div>
    </form>
</body>
</html>
